import axios from "axios"
import { Toast } from 'vant'
const service =axios.create({
headers:{
    DeviceType: 'h5',
    Authorization:'Bearer '+JSON.parse(localStorage.getItem('login')).remember_token,
}
})
service.interceptors.request.use((config)=>{
    // var arr=JSON.parse(localStorage.getItem('login'))||[]
    // var obj={
    //     Authorization:'Bearer '+arr.remember_token,
    // }
    // config.headers=obj
    Toast.loading({
        message: '加载中...',
        forbidClick: true,
      });
    return config
})
//响应拦截器
service.interceptors.response.use((config) => {

    Toast.clear()
    return config
  })
const Request = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            ...params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}


export default Request